<template>
  <div class="home">
    <!-- container容器布局 -->
    <el-container v-show="!$route.meta.requiresAuth">
      <el-header>
        <img src="./assets/img/text-logo.png" alt="无法加载图片" />
        <h1>后台管理系统</h1>
        <!-- 头部右侧下拉菜单 -->
        <el-dropdown>
          <span class="el-dropdown-link">
            管理员<i class="el-icon-arrow-down el-icon--right"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>个人中心</el-dropdown-item>
            <el-dropdown-item>设置</el-dropdown-item>
            <el-dropdown-item>
              <div @click="toLogin">退出</div>
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </el-header>
      <el-container>
        <!-- 左侧菜单 -->
        <el-menu
          router
          default-active="1-4-1"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
          :collapse="isCollapse"
          background-color="rgba(0,0,0,.1)"
        >
          <i
            v-show="!isCollapse"
            class="el-icon-s-fold"
            @click="leftMenuSwitch"
          ></i>
          <i
            v-show="isCollapse"
            class="el-icon-s-unfold"
            @click="leftMenuSwitch"
          ></i>

          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-paperclip"></i>
              <span slot="title">可视化大数据</span>
            </template>
            <el-menu-item-group>
              <span slot="title"></span>
              <el-menu-item index="/index">大数据图表</el-menu-item>
            </el-menu-item-group>
          </el-submenu>

          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span slot="title">物业服务</span>
            </template>
            <el-menu-item-group>
              <span slot="title"></span>
              <el-menu-item index="/expressage">快递管理</el-menu-item>
              <el-menu-item index="/repair">报修服务</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span slot="title">小区运营</span>
            </template>
            <el-menu-item-group>
              <span slot="title"></span>
              <el-menu-item index="/staff" @click="noTo">人事管理</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="4">
            <template slot="title">
              <i class="el-icon-document"></i>
              <span slot="title">小区缴费</span>
            </template>
            <el-menu-item-group>
              <span slot="title"></span>
              <el-menu-item index="/money">收费管理</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="5">
            <template slot="title">
              <i class="el-icon-setting"></i>
              <span slot="title">街道/社区</span>
            </template>
            <el-menu-item-group>
              <span slot="title"></span>
              <el-menu-item index="/user">业主管理</el-menu-item>
              <el-menu-item index="/news">街道新闻</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>

        <el-container>
          <!-- 占位视图 -->
          <router-view />
        </el-container>
      </el-container>
    </el-container>

    <!-- 登录 -->
    <router-view v-show="$route.meta.requiresAuth" />
  </div>
</template>

<script>
// import {Toast} from "element-ui";
export default {
  name: "",
  data() {
    return {
      isCollapse: false,
      obj: {},
    };
  },
  methods: {
    leftMenuSwitch() {
      this.isCollapse = !this.isCollapse;
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    toLogin() {
      // console.log(111);
      localStorage.removeItem("communityUser", JSON.stringify(this.ruleForm));
      this.$router.push({ path: "/login" });
    },
    // 经理与员工权限区分
    noTo() {
      if (this.obj.staff_status == "1") {
        this.$router.push({ path: "/" });
        this.$message({
          message: "警告哦,你没有此权限！！",
          type: "warning",
        });
      } else {
        this.$router.push({ path: "/staff" });
      }
    },
  },
  components: {},
  created() {
    var text = localStorage.getItem("communityUser");
    this.obj = JSON.parse(text);
    console.log(this.obj);
  },
};
</script>
<style lang="scss" scoped>
@import "./assets/css/common.css";
body,
html {
  body .home .el-container[data-v-7ba5bd90],
  html .home .el-container[data-v-7ba5bd90] {
    height: 100%;
  }
  .home {
    height: 100%;
    .el-container {
      height: 100px;
      .el-container {
        height: 100%;
        .el-menu {
          height: 100%;
        }
      }
    }
  }
}

// 左侧导航栏的样式
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.el-menu-vertical-demo {
  .el-icon-s-fold,
  .el-icon-s-unfold {
    font-size: 24px;
    padding: 30px 18px;
  }
}

// container容器的样式
.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
}
.el-header {
  // padding: 0 40px;
  position: relative;
  img {
    position: absolute;
    left: 0px;
    height: 60px;
    width: 200px;
  }
  h1 {
    position: absolute;
    left: 900px;
  }
  // 下拉菜单样式
  .el-dropdown {
    position: absolute;
    right: 100px;
  }
  .el-dropdown-link {
    cursor: pointer;
    color: #333;
    font-size: 20px;
  }
  .el-icon-arrow-down {
    font-size: 20px;
  }
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  line-height: 160px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
</style>
